import {cloneDeep} from "lodash";
export function useFormTemplate<D>(data: D){
    const sourceData = cloneDeep(data)
    function createPopupDataTemplate<T extends DataBind>(data: T | undefined = undefined){
        if(data === undefined){
            return sourceData
        }
        let obj: {[key: string]: any} = {}
        for (let key in sourceData){
            obj[key] = data[key]
        }
        obj.id = data.id
        return obj
    }

    return {
        createPopupDataTemplate
    }
}

type DataBind = {
    id: string | number,
    [key: string]: any
}
